package thread;

import java.util.Random;

public class TwoThreadTest {
	public static int num = 0;
	public static void main(String[] args) {		
		new Thread(new Shop()).start(); 
		new Thread(new Number100()).start();
	}
	
}
class Shop implements Runnable{
	Random random=new Random(); 
	@Override
	public void run() {
		while(true){
			System.err.print("#");
			if(TwoThreadTest.num>99) break;
			try {
				Thread.sleep(
						random.nextInt(90)+10);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
class Number100  implements Runnable{

	@Override
	public void run() {
		for (int i=0 ; i< 101 ; i++){
			TwoThreadTest.num=i;
			System.out.print(i);
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}

